package com.weimei.conversionTreasure.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.chad.library.BR;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.app.AppViewModelFactory;
import com.weimei.conversionTreasure.databinding.ActivitySaveXlBinding;
import com.weimei.conversionTreasure.viewModel.AddJxsVM;
import com.weimei.conversionTreasure.viewModel.SaveXlVM;

import me.goldze.mvvmhabit.base.BaseActivity;

public class SaveXlActivity extends BaseActivity<ActivitySaveXlBinding, SaveXlVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_save_xl;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public SaveXlVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, (ViewModelProvider.Factory) factory).get(SaveXlVM.class);
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        binding.back.setOnClickListener(v -> finish());

        binding.tvXl.setOnClickListener(view -> {
            selCC();
            viewModel.onResume();
        });

        binding.tvCc.setOnClickListener(view -> {
            selXL();
            viewModel.onResume();
        });

    }

    private void selCC() {
        binding.tvXl.setTextSize(18);
        binding.tvXl.setTextColor(Color.parseColor("#2A373A"));
        binding.tvCc.setTextSize(12);
        binding.tvCc.setTextColor(Color.parseColor("#6C7D7E"));
        viewModel.type.set("1");
    }

    private void selXL() {
        binding.tvCc.setTextSize(18);
        binding.tvCc.setTextColor(Color.parseColor("#2A373A"));
        binding.tvXl.setTextSize(12);
        binding.tvXl.setTextColor(Color.parseColor("#6C7D7E"));
        viewModel.type.set("0");
    }
}